Skip to content

feat: perf workflow + enhance hooks/skills - #151

Merged
avifenesh merged 6 commits into
mainfrom
perf-hardening
Jan 29, 2026
Merged

feat: perf workflow + enhance hooks/skills#151
avifenesh merged 6 commits into
mainfrom
perf-hardening

Conversation

@avifenesh

Copy link
Copy Markdown
Collaborator

Summary

  • add perf workflow phases, args parsing, code-paths tracking, and required docs
  • add hooks/skills analyzers to enhance + MCP support and docs updates
  • sync lib updates across plugins and add tests for new analyzers

Testing

  • npm test -- tests/enhance-hooks-skills-analyzer.test.js
  • npm run validate

Comment thread lib/perf/checkpoint.js Fixed
Comment thread plugins/audit-project/lib/perf/checkpoint.js Fixed
Comment thread plugins/deslop/lib/perf/checkpoint.js Fixed
Comment thread plugins/drift-detect/lib/perf/checkpoint.js Fixed
Comment thread plugins/enhance/lib/perf/checkpoint.js Fixed
Comment thread plugins/next-task/lib/perf/checkpoint.js Fixed
Comment thread plugins/perf/lib/perf/checkpoint.js Fixed
Comment thread plugins/repo-map/lib/perf/checkpoint.js Fixed
Comment thread plugins/ship/lib/perf/checkpoint.js Fixed
Comment thread plugins/sync-docs/lib/perf/checkpoint.js Fixed
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @avifenesh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the toolset by introducing a robust, multi-phase performance investigation workflow. It also refines the existing code quality analysis capabilities by adding specialized analyzers for hooks and skills, ensuring better adherence to best practices for these components. These additions are supported by comprehensive documentation and testing, ensuring reliability and ease of use across various platforms.

Highlights

  • New Performance Investigation Workflow (/perf): Introduced a comprehensive command for structured performance investigations, including phases for baselining, breaking point analysis, constraint testing, hypothesis generation, code path analysis, profiling, optimization, decision making, and consolidation.
  • Enhanced /enhance Command: Extended the existing /enhance command with two new analyzers: hooks-enhancer and skills-enhancer, providing checks for frontmatter completeness, structure, and trigger phrase clarity in hook and skill definitions.
  • Extensive Testing for New Features: Added dedicated test suites for the new performance workflow components (argument parsing, baselines, benchmarks, breaking points, checkpoints, code paths, consolidation, constraints, logging, optimization, profilers, profiling, schemas, state management) and the new enhance analyzers.
  • Documentation Updates: Updated marketplace.json, CHANGELOG.md, README.md, ARCHITECTURE.md, CROSS_PLATFORM.md, and USAGE.md to reflect the new /perf command and the expanded capabilities of /enhance.
  • Cross-Platform Library Sync: Synchronized the new enhance and perf library files across multiple plugins (audit-project, deslop, drift-detect, enhance, next-task, repo-map, ship, sync-docs) to ensure consistent functionality and support.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new /perf plugin for rigorous performance investigations, adding it to the marketplace, CLI installation scripts, and documentation across various files like README.md, CHANGELOG.md, and docs/reference/AGENTS.md. The /perf plugin includes extensive new modules for argument parsing, baseline management, benchmarking, breaking point detection, checkpointing, code path analysis, consolidation, constraint running, experiment execution, investigation state management, and language-specific profilers (Go, Java, Node, Python, Rust), along with dedicated agents and skills. Concurrently, the existing /enhance plugin is expanded to include new hooks and skills analyzers, which are integrated into its orchestrator, MCP tool definitions, and documentation. The review comments highlight critical path traversal vulnerabilities in the getInvestigationLogPath and getBaselinePath functions within the lib/perf/investigation-state.js and lib/perf/baseline-store.js modules, respectively, where user-controlled input is directly used to construct file paths without proper validation, potentially allowing malicious users to write files outside intended directories.

Comment on lines +127 to +133
function getInvestigationLogPath(id, basePath = process.cwd()) {
if (!id) {
throw new Error('Investigation id is required');
}
const { logDir } = ensurePerfDirs(basePath);
return path.join(logDir, `${id}.md`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The id parameter, which can be user-controlled via the --id CLI flag, is used directly in path.join to construct a file path. This creates a path traversal vulnerability. A malicious user could provide an id like ../../../../etc/passwd to write the log file outside the intended directory. The final path should be validated to ensure it's within the logDir. This aligns with the repository rule to always validate input paths to prevent path traversal vulnerabilities.

function getInvestigationLogPath(id, basePath = process.cwd()) {
  if (!id) {
    throw new Error('Investigation id is required');
  }
  const { logDir } = ensurePerfDirs(basePath);
  const logPath = path.join(logDir, `${id}.md`);
  validatePathWithinBase(logPath, logDir);
  return logPath;
}
References
  1. Always validate input paths to prevent path traversal vulnerabilities. Ensure all file operations are constrained within the intended project directory.

Comment on lines +45 to +50
function getBaselinePath(version, basePath = process.cwd()) {
if (!version) {
throw new Error('Baseline version is required');
}
return path.join(ensureBaselineDir(basePath), `${version}.json`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The version parameter, which can be user-controlled via the --version CLI flag, is used directly in path.join to construct a file path. This creates a path traversal vulnerability, allowing a user to write a baseline file outside the intended directory (e.g., with a version like ../../foo). The final path should be validated to ensure it is within the baselineDir. This aligns with the repository rule to always validate input paths to prevent path traversal vulnerabilities.

References
  1. Always validate input paths to prevent path traversal vulnerabilities. Ensure all file operations are constrained within the intended project directory.

@github-actions

Copy link
Copy Markdown

Code review

I found one issue that needs to be addressed:

Missing lib/perf export from lib/index.js

File: lib/perf/index.js (lines 24-41)
Link: https://github.com/avifenesh/awesome-slash/blob/74a12d33543deb10e2bf908569310fa8c176f942/lib/perf/index.js#L23-L42

The new lib/perf module needs to be exported from the main library entry point.

Issue: The new-lib-module.md checklist (required by CLAUDE.md Rule #5) requires all new lib modules to be exported from lib/index.js.

Required change: Add to lib/index.js:

const perf = require('./perf');

And include perf in the module.exports object around line 221-230.


Summary: Otherwise the code looks good. No bugs found in the new performance workflow modules or enhance hooks/skills analyzers. Good test coverage and documentation.

@github-actions

Copy link
Copy Markdown

Code Review

I've reviewed this PR and found 3 CLAUDE.md compliance issues. I'll post inline comments for each with specific fix suggestions.

@github-actions

Copy link
Copy Markdown

Issue 1: Model Selection Violation for Enhancer Agents

Files:

  • plugins/enhance/agents/hooks-enhancer.md (line 5)
  • plugins/enhance/agents/skills-enhancer.md (line 5)

Problem:
Both new enhancer agents specify model: sonnet instead of model: opus, violating CLAUDE.md model selection guidelines.

CLAUDE.md Rule:

Complexity Model When to Use
Opus Major components requiring real reasoning Enhancers, reviewers, analyzers where imperfection compounds

Key Insight: For enhancers/analyzers, the quality loss is exponential - imperfections multiply across all items reviewed.

Examples:

  • /enhance:agent uses opus - false positives damage agent quality across entire codebase

Fix:
Change line 5 in both files from:

model: sonnet

To:

model: opus

Reference: See CLAUDE.md Model Selection Guidelines

@github-actions

Copy link
Copy Markdown

Issue 2: Missing lib/perf Export from lib/index.js

File: lib/index.js

Problem:
The new lib/perf/ module was created (23 files) but is not exported from lib/index.js, making it inaccessible to code that imports from the main library entry point.

CLAUDE.md Rule:
From checklists/new-lib-module.md Section 2:

2. Export from lib/index.js

Add import:

const newModule = require('./new-module');

Add to exports:

module.exports = {
  // ... existing
  newModule,
};

Fix:
Add to lib/index.js:

  1. After line 28, add:
const perf = require('./perf');
  1. In the module.exports object (around line 230), add:
module.exports = {
  platform,
  patterns,
  state,
  utils,
  config,
  sources,
  xplat,
  enhance,
  repoMap,
  perf,  // Add this
  // ...
};

Reference: See new-lib-module.md checklist

@github-actions

Copy link
Copy Markdown

Issue 3: Missing CHANGELOG.md Entry for Performance Workflow

File: CHANGELOG.md (Unreleased section, lines 8-17)

Problem:
The PR introduces a comprehensive performance investigation workflow system (new /perf command, plugin with agents/hooks/skills, and lib/perf/ modules with 23 files), but this major feature addition is not documented in CHANGELOG.md. Only the hooks/skills analyzer enhancements are documented in the Unreleased section.

CLAUDE.md Rule:

No summary files - No *_AUDIT.md, *_SUMMARY.md, *_COMPLETION.md. Use CHANGELOG.md.

What's Missing:
The PR adds:

  • New /perf command - Complete workflow for performance investigations
  • lib/perf/ module - 23 files implementing performance investigation infrastructure
  • plugins/perf/ plugin - Complete plugin structure with agents, commands, hooks, skills
  • Documentation - Performance requirements and research methodology docs
  • Comprehensive test coverage - 15 test files for the perf system

Fix:
Add to the "Added" section in CHANGELOG.md Unreleased (after line 13):

- **/perf Command** - New performance investigation workflow with multi-phase testing, profiling (Node.js, Python, Go, Rust, Java), baseline comparison, breaking point detection, and optimization runner
- **lib/perf Module** - Core performance investigation infrastructure including state management, checkpoint/rollback, experiment runner, and code path tracking

Reference: See CLAUDE.md Critical Rule #3

@github-actions

Copy link
Copy Markdown

Code Review

I've completed my review of this PR and found several issues that need to be addressed:

1. Missing CHANGELOG Entry for /perf Workflow

File: CHANGELOG.md (line 10)

The /perf workflow is missing from the CHANGELOG. Per CLAUDE.md Critical Rule #3, all notable changes must be documented in CHANGELOG.md.

This PR adds a major new feature (10-phase performance investigation framework with multi-language profiling support), which should be documented alongside the enhance hooks/skills entries.

Suggested addition:

- **/perf Plugin** - New performance investigation workflow with 10-phase structured approach, multi-language profilers (Node, Python, Go, Rust, Java), baseline establishment, breaking-point discovery, hypothesis generation, code-path analysis, optimization experiments, and decision gates

2. Missing lib/perf Export

File: lib/index.js (line 221)

The new lib/perf/ module is not exported from lib/index.js, which violates the new-lib-module.md checklist required by CLAUDE.md Critical Rule #5.

This prevents external code from importing the perf module using const { perf } = require('./lib').

Required changes:

  • Add const perf = require('./perf'); after line 28
  • Add perf, to the module.exports object around line 245

3. Command Injection Risk in Profiler Commands

Files: lib/perf/profilers/node.js (lines 10-14), and similar issues in python.js, go.js, rust.js, java.js

Security: The profiler commands use string interpolation with user-supplied options that are executed via execSync() in profiling-runner.js:27.

While current usage in perf.md doesn't pass profileOptions, the exported API accepts arbitrary options without sanitization, creating a command injection risk if extended in the future.

Example attack: { command: 'node; rm -rf /' }"node; rm -rf / --cpu-prof"

Recommendation: Use execFile or spawn with array arguments instead of string interpolation + execSync. This same issue exists in all profiler files.

4. Unused experimentRun1 Variable

File: lib/perf/optimization-runner.js (line 43)

Logic issue: The first benchmark run (experimentRun1) is executed but never used. Only experimentRun2 is parsed for metrics.

This creates an unfair comparison:

  • Baseline (line 36): measured "cold" (single run)
  • Experiment (lines 43-44): measured after warm-up (first run discarded)

If warm-up is intentional, the baseline should also have a warm-up run. If not, remove the first experiment run.

The comment on line 42 doesn't explain why there are two runs or why the first is discarded.


Summary: 4 issues found

  • 2 CLAUDE.md compliance violations (CHANGELOG, lib export)
  • 1 security issue (command injection)
  • 1 logic error (asymmetric benchmark comparison)

All issues have clear fixes outlined above.

@github-actions

Copy link
Copy Markdown

Code Review - 4 Issues Found

I found 4 issues that need to be addressed:


1. Missing /perf Workflow in CHANGELOG.md

File: CHANGELOG.md (line 10)

The CHANGELOG.md was updated to document the enhance hooks/skills analyzers but completely omits the new /perf workflow, which is a major feature addition.

CLAUDE.md Rule Violated:
Critical Rule #6: "Before delivering ANY work - Check the relevant checklist for completion requirements... Do not mark complete until ALL checklist items are done"

From checklists/new-command.md Step 5: "Update CHANGELOG.md to note the addition"

Reference:

The PR adds an entire new plugin with:

  • New command /perf
  • 6 new agents (perf-orchestrator, perf-analyzer, perf-code-paths, etc.)
  • 8 new skills (baseline, benchmark, profiling, etc.)
  • New lib modules under lib/perf/

Action: Please add a section to the Unreleased changelog documenting this major feature.


2. Missing /perf Plugin in ARCHITECTURE.md

File: docs/ARCHITECTURE.md (lines 57-228)

The /perf plugin and command are not documented in ARCHITECTURE.md plugin directory structure or commands lists across all three platforms (Claude Code, OpenCode, Codex).

CLAUDE.md Rule Violated:
Critical Rule #6: "Before delivering ANY work - Check the relevant checklist for completion requirements... Do not mark complete until ALL checklist items are done"

From checklists/new-command.md Step 5: "Update docs/ARCHITECTURE.md to add to commands list if significant"

Reference:

Missing sections:

  • Plugin directory tree (lines 57-66) missing perf/
  • Claude Code commands list (line 153) missing /perf
  • OpenCode commands list (line 165) missing /perf
  • Codex skills list (line 193) missing $perf
  • Command Compatibility table (lines 219-228) missing /perf row

The perf plugin was correctly added to bin/cli.js for all three platforms, but ARCHITECTURE.md was not updated accordingly.

Action: Please add /perf to all command lists and the compatibility table in ARCHITECTURE.md.


3. Path Traversal Vulnerability in getInvestigationLogPath

File: lib/perf/investigation-state.js (line 132)

The id parameter is directly concatenated into the file path without sanitization, allowing path traversal attacks.

Issue: The --id argument is user-controlled via command-line input (documented in perf.md, parsed at line 78), passed directly to initializeInvestigation, and then used unsanitized in this function.

Exploit scenario:
/perf --id "../../../../../../tmp/malicious"

This would write to /tmp/malicious.md instead of the intended .claude/perf/investigations/ directory.

Evidence:

Suggested fix:

function getInvestigationLogPath(id, basePath = process.cwd()) {
  if (!id) {
    throw new Error('Investigation id is required');
  }
  // Sanitize id to prevent path traversal
  if (id.includes('..') || id.includes('/') || id.includes('\\')) {
    throw new Error('Investigation id contains invalid characters');
  }
  const { logDir } = ensurePerfDirs(basePath);
  return path.join(logDir, `${id}.md`);
}

4. Unused Variable - Dead Code

File: lib/perf/optimization-runner.js (line 43)

The variable experimentRun1 is assigned but never used. The code runs the benchmark twice but only uses the second result.

Issue: If this is intentional warmup behavior, it should be documented. Otherwise, this wastes significant time (minimum 60 seconds based on DEFAULT_MIN_DURATION).

Current code:

const experimentRun1 = runBenchmark(command, { duration: DEFAULT_MIN_DURATION, env });
const experimentRun2 = runBenchmark(command, { duration: DEFAULT_MIN_DURATION, env });
const experimentMetrics = parseMetrics(experimentRun2.output); // Only uses experimentRun2

Recommended fix: If this is intentional warmup, document it clearly:

// Run once to warm up the system (cache, JIT, etc.)
runBenchmark(command, { duration: DEFAULT_MIN_DURATION, env });

// Run again for actual measurement
const experimentRun = runBenchmark(command, { duration: DEFAULT_MIN_DURATION, env });
const experimentMetrics = parseMetrics(experimentRun.output);

Or if both runs should be used for statistical validity, implement proper averaging or comparison.

@avifenesh
avifenesh merged commit 9b4cf5b into main Jan 29, 2026
6 checks passed
@avifenesh
avifenesh deleted the perf-hardening branch January 29, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants